﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DZPK
{
    public partial class Form1 : Form
    {
        private Player player = null;
        private PlayEngine engine = null;

        public Form1()
        {
            InitializeComponent();

            this.listView1.View = View.Details;

            ColumnHeader ch = new ColumnHeader();
            ch.Text = "消息";
            ch.Width = 1000;
            ch.TextAlign = HorizontalAlignment.Left;
            this.listView1.Columns.Add(ch);

            Control.CheckForIllegalCrossThreadCalls = false;

            SetStyle(ControlStyles.DoubleBuffer | ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
            UpdateStyles(); 

            player = new Player();
            player.SetNotifyWnd(this);

            engine = PlayEngine.GetPlayEnginInstance();
            engine.TableManagerInstance.InitializeRooms();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //player.ConnectToSever("120.132.147.4", 7109);
            player.Test_SendLoginToServer();
        }

        private void button2_Click(object sender, EventArgs e)
        {

        }

        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void button3_Click(object sender, EventArgs e)
        {
            player.SendRequestRoomInfo();
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        public void AddMessage(string msg)
        {
            ListViewItem lvi = new ListViewItem();
            lvi.Text = msg;
            this.listView1.Items.Add(lvi);
        }

        private void button4_Click(object sender, EventArgs e)
        {
            player.Test_FindFreeSeatToSit();
        }

        private void button5_Click(object sender, EventArgs e)
        {
            player.SendClientUserStand();
        }

        private void button9_Click(object sender, EventArgs e)
        {
            player.SendClientChipin(CardOption.CHIPIN_FOLD, 0, player.userkey);
        }

        private void button8_Click(object sender, EventArgs e)
        {

        }

        private void button7_Click(object sender, EventArgs e)
        {
            player.SendClientChipin(CardOption.CHIPIN_CHECK, 0, player.userkey);
        }

        private void button6_Click(object sender, EventArgs e)
        {
            player.SendClientUserLogout();
        }
    }
}
